//
// C++ Interface: dirscanner
//
// Description:
//
//
// Author: Ernesto Barragan <ernestus *at* gmail.com>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef DIRSCANNER_H
#define DIRSCANNER_H

#include <QObject>
#include <QString>
#include <QStringList>
#include <QDir>

/**
Scans a directory looking for file matches

	@author Ernesto Barragan <ernestus *at* gmail.com>
*/
class DirScanner : public QObject
{
    Q_OBJECT
public:
    DirScanner();
    ~DirScanner();

    // setup methods
    void setRecursive( const bool recursive ) ; //inline
    bool isRecursive() const ; //inline

    void setSymlinkFollowed( const bool symlinks ) ; //inline
    bool isSymlinkFollowed() const ; //inline

    void  setNameFilter( const QString& filter ) ;//inline
    QString nameFilter() const ; //inline

    void startScan( const QString path ) const ;
    void startScan( const QStringList path ) const ;

    //@todo implement those
    // void setSorting
    // sorting

signals:
    void file( QString filename )  ;
    void directory( QString path ) ;

protected:
    /*
        You can override this method if you don't want to pay
        the cost of emitting a signal
    */
    virtual void fileFound( QString filename ) ;
    virtual void directoryFound( QString path ) ;

private:
    bool m_recursive ;
    bool m_symlinks ;
    QString m_nameFilter ;
    QDir::SortFlags m_sorting ;
};

#endif
